<?php
$protocolo=$_POST['protocolo'];
include_once 'includes/utilities.php';
include_once 'includes/config.php';
OpenDB();
if ($_POST['tipo']=="paciente"){
    $query_protocolo= mysql_query("SELECT paciente.mail as mail FROM protocolo JOIN paciente ON protocolo.id_paciente=paciente.id_paciente WHERE numero_protocolo='".$protocolo."'");
    if (@mysql_num_rows($query_protocolo)>0)
        echo mysql_result($query_protocolo,0,'mail');
    else
        echo "";
}
else{
    $query_protocolo= mysql_query("SELECT medico.mail as mail FROM protocolo JOIN medico ON protocolo.id_medico=medico.id_medico WHERE numero_protocolo='".$protocolo."'");
    if (@mysql_num_rows($query_protocolo)>0)
        echo mysql_result($query_protocolo,0,'mail');
    else
        echo "";    
}
?>
